<?php
/**
 * Created by PhpStorm.
 * User: zcq
 * Date: 2018/11/13
 * Time: 10:05
 */

namespace app\admin\controller;


use think\Db;

class Order extends Base
{
    public $table = 'order';
    public function index()
    {
        $keyword = input('keyword');
        $status = input('status');
        $where = null;
        if($keyword)
            $where['a.order_no|b.nickname|c.name'] = ['like','%'.$keyword.'%'];
        if($status)
            $where['a.status'] = ['eq',$status];
        if(!$where)
            $where = '1=1';
        $data['list'] = Db::name($this->table)
            ->alias('a')
            ->join('member b','b.id=a.member_id','left')
            ->join('magazine c','c.id=a.pid','left')
            ->where($where)
            ->order('a.id desc')
            ->field('a.*,b.nickname,c.name')
            ->paginate();
        $data['page'] = $data['list']->render();
        $this->assign('data',$data);
        $this->assign('status',$status);
        $this->assign('keyword',$keyword);
        return $this->fetch();
    }
}